#include "OurKickInWithoutBallBehavior.h"

/**
 *
 * pri zahravani nasho vhadzovania,bud sa posunie hrac na urcitu poziciu 
 * alebo na poziciu kde je lopta, aby mohol rozohrat,
 * najrpv sa urci kto bude vhadzovat a ak je to moje cislo tak sa posuniem ku lopte
 *
 */
void OurKickInWithoutBallBehavior::Behave(void)
{
	// Rozohravatel nasho vhadzovania
	int nKickInUniform;

	if(DATA_STORAGE.ballPosition.GetY() < 0)
	{
		nKickInUniform = 6;

		if(DATA_STORAGE.myUniform == nKickInUniform)
		{
			GetRunToPositionBehaviour()->Behave(DATA_STORAGE.ballPosition, 1);
			return;
		}
		else if(DATA_STORAGE.myUniform == 3)
		{
			GetRunToPositionBehaviour()->Behave(Point(DATA_STORAGE.ballPosition.GetX() - 12, DATA_STORAGE.ballPosition.GetY() + 8), 1);
			return;
		}
		else if(DATA_STORAGE.myUniform == 5)
		{
			GetRunToPositionBehaviour()->Behave(Point(DATA_STORAGE.ballPosition.GetX(), DATA_STORAGE.ballPosition.GetY() + 10), 1);
			return;
		}
		else if(DATA_STORAGE.myUniform == 10)
		{
			GetRunToPositionBehaviour()->Behave(Point(DATA_STORAGE.ballPosition.GetX() + 12, DATA_STORAGE.ballPosition.GetY() + 3), 1);
			return;
		}
		else
		{	
			DATA_STORAGE.ignoreBall = true;
		}
	}
	else if(DATA_STORAGE.ballPosition.GetY() > 0)
	{
		nKickInUniform = 7;

		if(DATA_STORAGE.myUniform == nKickInUniform)
		{
			GetRunToPositionBehaviour()->Behave(DATA_STORAGE.ballPosition, 1);
			return;
		}
		else if(DATA_STORAGE.myUniform == 4)
		{
			GetRunToPositionBehaviour()->Behave(Point(DATA_STORAGE.ballPosition.GetX() - 12, DATA_STORAGE.ballPosition.GetY() - 8), 1);
			return;
		}
		else if(DATA_STORAGE.myUniform == 5)
		{
			GetRunToPositionBehaviour()->Behave(Point(DATA_STORAGE.ballPosition.GetX(), DATA_STORAGE.ballPosition.GetY() - 10), 1);
			return;
		}
		else if(DATA_STORAGE.myUniform == 11)
		{
			GetRunToPositionBehaviour()->Behave(Point(DATA_STORAGE.ballPosition.GetX() + 12, DATA_STORAGE.ballPosition.GetY() - 3), 1);
			return;
		}
		else
		{
			DATA_STORAGE.ignoreBall = true;
		}
	}
}
